/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.ucase.casemain.controller;

import com.alibaba.fastjson.JSON;
import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.common.utils.CustomCheckParamUtil;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.*;
import com.icinfo.cloud.provider.punish.ucase.casemain.service.ICaseAppendixRecordService;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseAttachmentInfoVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 描述: 案件附件表-trj case_appendix_record 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年02月25日
 */
@RestController
@RefreshScope
@RequestMapping("/punish/ucase/case/main/attachment")
@Slf4j
public class CaseAppendixRecordController extends BaseController {
    @Resource
    private ICaseAppendixRecordService caseAppendixRecordService;

    /**
     * 【V1.0.0】描述：获取案件附件列表
     *
     * @param queryDto {@link CaseAttachmentInfoQueryDto}
     * @return {@link Result<List<CaseAttachmentInfoVo>} 案件附件列表
     * @author xiangyuyu
     * @date 2022-02-27 09:49
     */
    @PostMapping("/getCaseAttachmentList")
    @ApiOperation(value = "【V1.0.0】描述：获取案件附件列表", httpMethod = "POST")
    public Result<List<CaseAttachmentInfoVo>> getCaseAttachmentList(@RequestBody @Validated CaseAttachmentInfoQueryDto queryDto) {
        List<CaseAttachmentInfoVo> list = caseAppendixRecordService.getCaseAttachmentList(queryDto);
        return Result.success(Constant.STRING_GET_SUCCESS, list);
    }

    /**
     * 【V1.0.0】描述：获取案件证据列表
     *
     * @param queryDto {@link CaseAttachmentInfoQueryDto}
     * @return {@link Result<List<CaseAttachmentInfoVo>} 案件附件列表
     * @author cyy
     * @date 2022-03-04
     */
    @PostMapping("/getCaseEvidenceList")
    @ApiOperation(value = "【V1.0.0】描述：获取案件证据列表", httpMethod = "POST")
    public Result<List<CaseAttachmentInfoVo>> getCaseEvidenceList(@RequestBody @Validated CaseEvidenceQueryDto queryDto) {
        CaseAttachmentInfoQueryDto qto = new CaseAttachmentInfoQueryDto();
        qto.setCaseId(queryDto.getCaseId());
        qto.setDocumentCatalogCode(queryDto.getDocumentCatalogCode());
        qto.setAttachmentTypeId("EVIDENCE");
        List<CaseAttachmentInfoVo> list = caseAppendixRecordService.getCaseAttachmentList(qto);
        return Result.success(Constant.STRING_GET_SUCCESS, list);
    }

    /**
     * 【V1.0.0】描述：根据唯一标识查询案件附件信息
     *
     * @param id 唯一标识
     * @return {@link Result<CaseAttachmentInfoVo>} 案件附件信息
     * @author xiangyuyu
     * @date 2022-02-27 09:49
     */
    @PostMapping("/getCaseAttachmentInfo")
    @ApiOperation(value = "【V1.0.0】描述：根据唯一标识查询案件附件信息", httpMethod = "POST")
    public Result<CaseAttachmentInfoVo> getCaseAttachmentInfo(@RequestParam String id) {
        CaseAttachmentInfoVo vo = caseAppendixRecordService.getCaseAttachmentInfo(id);
        return Result.success(Constant.STRING_GET_SUCCESS, vo);
    }


    /**
     * 【V1.0.0】描述：删除案件关联附件
     *
     * @param id 唯一标识
     * @return {@link Result<String>} 删除结果
     * @author xiangyuyu
     * @date 2022-03-07 13:47
     */
    @PostMapping("/removeCaseAttachment")
    @ApiOperation(value = "【V1.0.0】描述：删除附件", httpMethod = "POST")
    public Result<String> removeCaseAttachment(@RequestParam String id) {
        return caseAppendixRecordService.removeCaseAttachment(id);
    }

    /**
     * 附件管理-保存更新附件
     *
     * @param caseStageAppendixSaveDto
     * @return: com.icinfo.framework.common.web.Result<java.lang.String>
     * @author sunjiefei
     * @date 2023-04-06
     */
    @PostMapping("/saveCaseAttachmentInfo")
    public Result<String> saveCaseAttachmentInfo(@RequestBody @Validated CaseStageAppendixSaveDto caseStageAppendixSaveDto) {
        return caseAppendixRecordService.saveCaseAttachmentInfo(caseStageAppendixSaveDto);
    }

    /**
     * 附件管理-查询附件
     *
     * @param caseAppendixQueryDto
     * @return: com.icinfo.framework.common.web.Result<java.util.List<com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseAttachmentInfoVo>>
     * @author sunjiefei
     * @date 2023-04-06
     */
    @PostMapping("/getCaseAttachments")
    public Result<List<CaseAttachmentInfoVo>> getCaseAttachments(@RequestBody @Validated CaseAppendixQueryDto caseAppendixQueryDto) {
        List<CaseAttachmentInfoVo> attachmentInfoVos = caseAppendixRecordService.getCaseAttachments(caseAppendixQueryDto);
        return Result.success(Constant.STRING_GET_SUCCESS, attachmentInfoVos);
    }

}